package Ioperation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Borrow implements Ioperate{
    @Override
    public void operate(BookList bookList) {
        System.out.println("请输入你要借阅图书书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();

        int curSize = bookList.getCurSize();
        for (int i = 0; i < curSize; i++) {
            Book book = bookList.getBooks(i);
            if(book.getName().equals(name)){
                if(book.isIs_borrowed() == false){
                    System.out.println("该书已被你成功借阅......");
                    book.setIs_borrowed(true);
                }else{
                    System.out.println("该书已被借阅，无法被再次借阅.....");
                }
                return;
            }
        }

        System.out.println("未查询到此书......");
    }
}
